<template>
<div>
  <!--上部导航栏start-->
<admin-nav/>
<!--上部导航栏end-->
<!--上部导航栏end-->
<div class="container-fluid">
    <div class="row">
        <!--左侧导航栏start-->
        <admin-left/>
        <!--左侧导航栏end-->
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">添加项目分类</h1>

            <div class="panel panel-default">
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        添加项目
                    </div>
                </div>
                <div class="panel-body">

                    <div class="table-responsive ">
                        <form>
                            <div class="form-group">
                                <input type="text" class="form-control" id="type_name" placeholder="分类名称" v-model="typeName">
                            </div>

                            <div class="form-group">
                               <textarea class="form-control" rows="3" placeholder="分类描述" v-model="detail"></textarea>
                            </div>
                            &nbsp;&nbsp;
                            <button type="button" class="btn btn-default btn-primary pull-right" @click="addType()">添加</button>
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

</div>
</template>

<script>
export default {
    data() {
        return {
            typeName:'',
            detail:''
        }
    },
    methods:{
        addType(){
            let type={}
            type.name=this.typeName,
            type.detail=this.detail
            this.$axios.post('http://localhost:8080/addType',type).then((result) => {
                console.log("返回了")
                if(result.data.code===1){
                this.$router.push('/all_classity')
                }else{
                console.log(result.data.msg);
                }
            }).catch(error => {
                console.error("未登录，请先登陆！");
                })
        }
    }
}
</script>

<style>
@import url("../../../../public/css/bootstrap.min.css");
@import url("../../../../public/css/dashboard.css");
@import url("../../../../public/css/dialog.css");
</style>